package com.beten.util;

import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;

import android.util.Log;
public class FileReader {
	private static final String TAG = "FileReader";
	BufferedInputStream in = null;
	Boolean isOpen=false;
	public void open(String fileName)
	{
	 try {
		 in = new BufferedInputStream(new FileInputStream(fileName));
		 } catch (FileNotFoundException e) { 
		 Log.e(TAG, e.toString());
		 return;
		 }  

		isOpen=true;
	}
	
	public int readData(byte[] data)
	{
		if(!isOpen)
			return -1;
		int size=-1;
		try {
			 size = in.read(data);
		} catch (IOException e) {
			 Log.e(TAG, e.toString());
		}
		return size;
	}
	public void close()
	{
		if(!isOpen)
			return;
		
	    try {
	    	   in.close();
	    	  } catch (IOException e) {
	    	  Log.e(TAG, e.toString());
	    	  } 

	}
}
